<?php
/**
 * This file is part of Task Agile.
 * Task Agile is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License.
 * Task Agile is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Task Agile.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category   TaskAgile
 * @package    Controller
 * @copyright  Copyright (c) 20010-2010 Estrada Virtual (http://estradavirtual.com.br)
 * @license    http://www.gnu.org/licenses/gpl.txt GPLv3
 * @version    $Id$
*/
class Task_ReportController extends Tev_Controller_Action
{
    public function indexAction()
    {
    }


    public function byProjectsAction()
    {
        $task = new Task();
        $select = $task->select(true)->setIntegrityCheck(false)
             ->join(array('p'  => 'project'), 'p.id = task.fk_project', array('projectName' => 'name', 'fk_enterprise'))
             ->join(array('pu' => 'project_user'), 'pu.fk_project = p.id', array())
             ->join(array('e'  => 'enterprise'), 'p.fk_enterprise = e.id', array('enterpriseName' => 'name'), array())
             ->where('pu.fk_user = ?', Zend_Auth::getInstance()->getIdentity()->id)
             ->order(array('enterpriseName', 'projectName', 'priority', 'name'));

        $this->view->tasks = $select->query()->fetchAll();
        $this->view->prioritys = $task->getPrioritys();
        $this->view->status    = $task->getStatus();

        // Users
        $user = new User();
        $rowSetUsers = $user->fetchAll(null, 'name');
        unset($user);
        $users = array();
        foreach ($rowSetUsers as $rowUser) {
            $users[$rowUser->id] = $rowUser->name;
        }
        $this->view->users = $users;
    }
}
